package org.example.controller;

import jakarta.annotation.Resource;
import org.example.dao.TestMapper;
import org.example.domain.Test;
import org.example.service.TestService;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: tang
 * @Description:
 * @Date 2025/6/5 23:06
 */
@RestController
@RequestMapping("/test")
public class TestController {

    @Resource
    TestService testService;

    @GetMapping("/testPage")
    public List<Test> testPage() {
        return testService.testPage();
    }

    @Transactional(rollbackFor = Exception.class)
    @GetMapping("/test")
    public Test test() {
        return testService.test();
    }

    @GetMapping("/test01")
    public Test test01() {
        return testService.test01();
    }

    @GetMapping("/test02")
    public Test test02() {
        return testService.test02();
    }

    @GetMapping("/test03")
    public String test03() {
        testService.test03();
        return "success";
    }

    @GetMapping("/test04")
    public String test04() throws Exception{
        testService.test04();
        return "success";
    }


}
